package distributedbank.requests;

import java.io.IOException;

import distributedbank.Wrapper;
import distributedbank.server.BankBranch;
/**
 * Snapshot Request is either internal or external, 
 * which means it originates either from bank branches or clientUIs
 */
public class SsRequest extends Request
{
    private static final long serialVersionUID = -1506136425646283601L;

    /**
     * Each internal SsRequest has a non-zero reqId. For each snapshot, the id is unique.</br>
     * The id's last digit shows the origin bank branch of the SsRequest.</br>
     * </br>
     * reqId == 0 shows the SsRequest comes from GUI.
     */
    private int reqId;

    private int srcBranchId;
    
    public SsRequest( int reqId, int srcBranchId ) {
        super( 0, 0, 0 );
        this.reqId = reqId;
        this.srcBranchId = srcBranchId;
    }
    /**
     * On receiving SsReq
     */
    public void runRequest( BankBranch bankBranch, Wrapper wrapper )
            throws IOException {
        bankBranch.recvSsReq( this.reqId, srcBranchId );
    }
}